<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ include file="../../base.jsp" %>//
<!DOCTYPE html>

<html>
<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>数据 - AdminLTE2定制版</title>
    <meta name="description" content="AdminLTE2定制版">
    <meta name="keywords" content="AdminLTE2定制版">
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <!-- 页面meta /-->
    <script src="${ctx}/plugins/jQuery/jquery-2.2.3.min.js"></script>
</head>

<body>
<div id="frameContent" class="content-wrapper" style="margin-left:0px;">
    <section class="content-header">
        <h1>
            货运管理
            <small>发票管理</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="all-admin-index.html"><i class="fa fa-dashboard"></i> 首页</a></li>
        </ol>
    </section>

    <script>
        function deleteById() {
            var id = getCheckId()
            if (id) {
                if ($('input[type=checkbox]:checked').attr("dataCong")==0) {
                    if (confirm("您确认要删除此条记录?")) {
                        location.href = "${ctx}/cargo/invoice/delete.do?id=" + id;
                    }
                }else{
                    alert("只能删除草稿")
                }
            } else {
                alert("请勾选要处理的记录,且只能勾选一个")
            }
        }
        
        function printExcel() {
            var id=getCheckId();
            var time=$('input[type=checkbox]:checked').attr("data-c")
            if (id){
                location.href='${ctx}/cargo/invoice/printExcel.do?id='+id+"&invoiceTime="+time;

            }else{
                alert("请勾选要导出的发票")
            }
        }

        //保存
        function createEdit(){//传递委托单的id
            location.href="${ctx}/cargo/invoice/toEdit.do";
        }
        function toAddFinance() {
            var invoiceId = getCheckId()
            if(invoiceId) {

                location.href="${ctx}/cargo/finance/toAdd.do?invoiceId="+invoiceId;

            }else{
                alert("请勾选待处理的记录，且每次只能勾选一个")
            }
        }
    </script>
    <!-- 正文区域 -->
    <section class="content">

        <!-- .box-body -->
        <div class="box box-primary">
            <div class="box-header with-border">
                <h3 class="box-title">发票列表</h3>
            </div>

            <div class="box-body">

                <!-- 数据表格 -->
                <div class="table-box">

                    <!--工具栏-->
                    <div class="pull-left">
                        <div class="btn-group">
                            <button type="button" class="btn btn-default" onclick="createEdit()" title="查看"><i class="fa fa-file-o"></i> 查看
                            </button>
                            <button type="button" class="btn btn-default" onclick="deleteById()" title="删除"><i
                                    class="fa fa-trash-o"></i> 删除
                            </button>
                            <button type="button" class="btn btn-default" onclick="toAddFinance()" title="财务报运单"><i class="fa fa-check"></i>财务报运单</button>
                            <button type="button" class="btn btn-default" onclick="printExcel()" title="导出Excel"><i class="fa fa-check"></i>导出Excel</button>
                            <button type="button" class="btn btn-default" title="导出PDF"><i class="fa fa-check"></i>导出PDF</button>
                            <button type="button" class="btn btn-default" onclick="window.location.reload()" title="刷新"><i class="fa fa-refresh"></i> 刷新
                            </button>
                        </div>
                    </div>
                    <div class="box-tools pull-right">
                        <div class="has-feedback">
                            <input type="text" class="form-control input-sm" placeholder="搜索">
                            <span class="glyphicon glyphicon-search form-control-feedback"></span>
                        </div>
                    </div>
                    <!--工具栏/-->

                    <!--数据列表-->
                    <table id="dataList" class="table table-bordered table-striped table-hover dataTable">
                        <thead>
                        <tr>
                            <th class="" style="padding-right:0px;">
                                <input id="selall" type="checkbox" class="icheckbox_square-blue">
                            </th>
                            <th class="sorting_asc">发票编号</th>
                            <th class="sorting_desc">报运合同号</th>
                            <th class="sorting_asc sorting_asc_disabled">贸易条款</th>
                            <th class="sorting_desc sorting_desc_disabled">发票金额</th>
                            <th class="sorting">发票时间</th>
                            <th class="text-center sorting">发票状态</th>

                        </tr>
                        </thead>
                        <tbody>

                        <c:forEach items="${page.list}" var="inv" varStatus="status">
                            <tr>
                                <td><input name="id" value="${inv.invoiceId}" type="checkbox" data-c="<fmt:formatDate value="${inv.invoiceTime}" pattern="yyyy-MM"/>" dataCong="${inv.status}"></td>
                                <td><input name="id" value="${inv.id}" type="checkbox" data-c="<fmt:formatDate value="${inv.invoiceTime}" pattern="yyyy-MM"/>" dataCong="${inv.status}"></td>
                                <td>${inv.invoiceId}</td>
                                <td>${inv.scNo}</td>
                                <td>${inv.tradeTerms}</td>
                                <td>${inv.invoiceMoney}</td>
                                <td><fmt:formatDate value="${inv.invoiceTime}" pattern="yyyy-MM"/></td>
                                <td><c:if test="${inv.status==0}">草稿</c:if>
                                    <c:if test="${inv.status==1}">已生成财务报运</c:if>
                                </td>
                            </tr>

                        </c:forEach>

                        </tbody>
                        <!--
                            <tfoot>
                            <tr>
                            <th>Rendering engine</th>
                            <th>Browser</th>
                            <th>Platform(s)</th>
                            <th>Engine version</th>
                            <th>CSS grade</th>
                            </tr>
                            </tfoot>-->
                    </table>
                    <!--数据列表/-->
                </div>
            </div>

            <div class="box-footer">
                <jsp:include page="../../common/page.jsp">
                    <jsp:param value="${ctx}/cargo/invoice/list.do" name="pageUrl"/>
                </jsp:include>
            </div>
        </div>
    </section>
</div>
</body>
</html>
